package com.example.test_memory

import android.content.Context

/**
 * @author ytx
 * @date 2025-10-10 08:17
 * @description
 */
class UserManager {
    //双重校验锁单例上下文
    private var mContext: Context? = null
    companion object{
        @Volatile //保证可见性、有序性
        private var INSTANCE: UserManager? = null
        fun getInstance(context: Context): UserManager {
            if (INSTANCE == null) {
                synchronized(UserManager::class.java) {
                    if (INSTANCE == null) {
                        INSTANCE = UserManager()
                        INSTANCE?.mContext = context
                    }
                }
            }
            return INSTANCE!!
        }
    }
}